import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/pages/login.vue'
import Home from '@/pages/home.vue'
import Index from '@/pages/index.vue'
import Product from '@/pages/product.vue'
import Detail from '@/pages/detail.vue'
import Cart from '@/pages/cart.vue'
import Order from '@/pages/order.vue'
import OrderConficom from '@/pages/orderConficom.vue'
import OrderList from '@/pages/orderList.vue'
import OrderPay from '@/pages/orderPay.vue'
import AliPay from '@/pages/aliPay.vue'
Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'Home',
    component: Home,
    redirect: '/index',
    //使用子路由
    children: [{
        path: 'index',
        name: 'index',
        component: Index,
      },
      {
        path: 'product/:id',
        name: 'Product',
        component: Product,
      },
      {
        path: 'detail/:id',
        name: 'detail',
        component: Detail,
      },
    ]
  },
  {
    path: '/cart',
    name: 'Cart',
    component: Cart,
  },
  {
    path: '/order',
    name: 'Order',
    component: Order,
    children: [{
        path: 'conficom',
        name: 'OrderConficom',
        component: OrderConficom,
      },
      {
        path: 'list',
        name: 'OrderList',
        component: OrderList,
      },
      {
        path: 'pay',
        name: 'OrderPay',
        component: OrderPay,
      },
      {
        path: 'aliPay',
        name: 'AliPay',
        component: AliPay,
      },
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
  }
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router